function resolve(moduleName) {
  return require.resolve(moduleName);
}
const isDev = process.env.NODE_ENV === "development"

module.exports = () => {
  const plugins = [
    // ["import", { "libraryName": "antd", "libraryDirectory": 'es', "style": true }],
    isDev && resolve("react-refresh/babel"),
    [
      resolve("@babel/plugin-transform-runtime"),
      {
        "absoluteRuntime": false,
        "corejs": 3,
        "helpers": true,
        "regenerator": true,
        "useESModules": false
      }
    ],
    "@babel/plugin-transform-modules-commonjs",
  ].filter(Boolean);
  return {
    presets: [
      resolve("@babel/preset-react"),
      [
        resolve("@babel/preset-env"),
        {
          targets: {
            browsers: [
              "last 2 versions",
              "Firefox ESR",
              "> 1%",
              "ie >= 9",
              "iOS >= 8",
              "Android >= 4",
            ],
          },
        },
      ],
    ],
    plugins,
  };
};